﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="OperationArea.aspx.cs"
    Inherits="Catering.Catering_Page.system.OperationArea" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="../../Style/center.css" rel="stylesheet" type="text/css" />
    <script src="../../Scripts/zhezhao.js" type="text/javascript"></script>
    <link href="../../Style/zhezhao.css" rel="stylesheet" type="text/css" />
    <script src="../../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <link href="../../Style/sysData.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
        //显示添加
        function Add() {
            $("#btnEdit").hide();
            $("#btnAdd").show();
            divshow("main", "bg");
        }

        //显示修改
        function Edit(cid) {
            $("#HidID").val(cid);

            $.ajax({
                type: "Post",
                url: "OperationArea.aspx/Get",
                data: "{'cid':'" + cid + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    $("#txt_AreaName").val(data.d[0] == null ? "" : data.d[0]);
                    $("#txt_AreaAdd").val(data.d[1] == null ? "" : data.d[1]);
                    $("#txt_Back").val(data.d[2] == null ? "" : data.d[2]);
                    $("#Drop_Company").val(data.d[3] == null ? "" : data.d[3]);
                    $("#btnEdit").show();
                    $("#btnAdd").hide();
                    divshow("main", "bg");
                }
            });
        }

        //添加数据
        function btn_Add() {
            var txt_AreaName = $("#txt_AreaName").val();
            var txt_AreaAdd = $("#txt_AreaAdd").val();            
            var txt_Back = $("#txt_Back").val();
            var txt_Company = $("#Drop_Company").val();

            $.ajax({
                type: "Post",
                url: "OperationArea.aspx/Add",
                data: "{'AreaName':'" + txt_AreaName + "','AreaAdd':'" + txt_AreaAdd + "','Back':'" + txt_Back + "','Company':'" + txt_Company + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    if (data.d == "OK") {
                        alert("保存成功！");
                        window.location.href = 'OperationArea.aspx';
                    }
                }
            });
        }

        //修改数据
        function btn_Edit() {
            var txt_AreaName = $("#txt_AreaName").val();
            var txt_AreaAdd = $("#txt_AreaAdd").val();            
            var txt_Back = $("#txt_Back").val();
            var txt_Company = $("#Drop_Company").val();
            var cid = $("#HidID").val();

            $.ajax({
                type: "Post",
                url: "OperationArea.aspx/Edit",
                data: "{'cid':'" + cid + "','AreaName':'" + txt_AreaName + "','AreaAdd':'" + txt_AreaAdd + "','Back':'" + txt_Back + "','Company':'" + txt_Company + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    if (data.d == "OK") {
                        alert("保存成功！");
                        window.location.href = 'OperationArea.aspx';
                    }
                }
            });
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <asp:HiddenField ID="HidID" runat="server" />
    <div style="height:36px; line-height:36px; font-size:13px;">&nbsp;当前位置：作业区</div>
    <%if (Catering.Toolss.IsVerification(Session["RoleID"].ToString(), "System_Data.aspx", "作业区操作"))
      { %>
    <div class="btn_list" style="margin-top:0px;">
        <table width="100%" border="0" cellpadding="0" cellspacing="0">
            <tr>
                <td align="right" height="30">
                    <input type="button" class="input_btn_a" value="添加" onclick="Add()" />
                </td>
                <td width="10"></td>
            </tr>
        </table>
    </div>
    <%} %>
    <div class="data_css">
        <table width="100%" border="1" cellpadding="0" cellspacing="0">
            <thead>
                <tr>
                    <th width="16%">
                        公司
                    </th>
                    <th width="18%">
                        作业区名称
                    </th>
                    <th width="15%">
                        作业区地址
                    </th>
                    <th width="15%">
                        备注
                    </th>
                    <th width="10%">
                        编辑
                    </th>
                    <th width="15%">
                        是否全局
                    </th>
                    <th width="10%">
                        删除
                    </th>
                </tr>
            </thead>
            <tbody>
                <asp:Repeater ID="Rep_OperationArea" runat="server" OnItemCommand="Rep_ItemCommand">
                    <ItemTemplate>
                        <tr>
                            <td>
                                <%#GetCompanyName(Eval("temp2") == null ? "" : Eval("temp2").ToString())%>&nbsp;
                            </td>
                            <td>
                                <%#Eval("AreaName")%>&nbsp;
                            </td>
                            <td>
                                <%#Eval("AreaAdd")%>&nbsp;
                            </td>
                            <td>
                                <%#Eval("Back")%>&nbsp;
                            </td>
                            <%if (Catering.Toolss.IsVerification(Session["RoleID"].ToString(), "System_Data.aspx", "作业区操作"))
                                  { %>
                            <td>
                                <img src="../../Images/file.gif" onclick="Edit('<%#Eval("id")%>')" style="cursor: pointer;" />
                            </td>
                            <td>
                                <%#(Eval("Temp1").ToString() == "" || Eval("Temp1").ToString()=="0") ? "是" : "否"%>
                                <asp:Button ID="btn_tiaoz" runat="server" Text="调整" CommandArgument='<%#Eval("id")%>' CommandName="tz" />
                            </td>
                            <td>
                                <asp:ImageButton ID="img_btn" runat="server" ImageUrl="../../Images/trash.gif" OnClientClick="return confirm('确认删除？');"
                                    CommandArgument='<%#Eval("id")%>' CommandName="del" />
                            </td>
                            <%}
                                  else
                                  { %>
                                  <td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>
                                <%} %>
                        </tr>
                    </ItemTemplate>
                </asp:Repeater>
            </tbody>
        </table>
    </div>
    <!--弹出层-->
    <div id="bg" class="bg">
    </div>
    <div id="main" class="center_div" style="width:430px; height:180px; padding: 0px;
        margin-top: -100px;">
        <div class="div_0207" style="width:428px; margin:0px; height:100%;">
            <h1><img src="../../Images/cp_h1_03.gif" />添加作业区信息</h1>
            <table width="100%">
                <tr>
                    <td align="right" height="30">公　司：</td>
                    <td colspan="3">
                         <asp:DropDownList ID="Drop_Company" runat="server" CssClass="select_input_bg"></asp:DropDownList>
                    </td>
                </tr>
                <tr>
                    <td align="right" height="30">名　称：</td>
                    <td><asp:TextBox ID="txt_AreaName" runat="server" CssClass="input_bg"></asp:TextBox></td>
                    <td align="right">地址：</td>
                    <td><asp:TextBox ID="txt_AreaAdd" runat="server" CssClass="input_bg"></asp:TextBox></td>
                </tr>
                <tr>
                    <td align="right">备　注：</td>
                    <td colspan="3"><asp:TextBox ID="txt_Back" runat="server" TextMode="MultiLine" CssClass="input_bg" style="width:98%; height:40px;"></asp:TextBox></td>
                </tr>
            </table>
            <table width="100%">
                <tr>
                    <td align="right">
                        <input type="button" id="btnAdd" onclick="btn_Add()" class="input_btn_a" value="提交" />
                        <input type="button" id="btnEdit" onclick="btn_Edit()" class="input_btn_a" value="提交" />
                    </td>
                    <td>
                        <input type="button" id="but_Close" onclick='divhidel("main","bg")' class="input_btn_a" value="关闭" />
                    </td>
                </tr>
            </table>
        </div>
    </div>
    </form>
</body>
</html>
